#include<bits/stdc++.h>
#define ll long long
using namespace std;
string s[1000005];
int n,m; 
int main(){
	ios::sync_with_stdio(0);
  	freopen("indian.in","r",stdin);
  	freopen("indian.out","w",stdout);
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		cin>>s[i];
		s[i]=' '+s[i]+' ';
	}
	for(int i=1;i<=n;i++){
		int lst=-1;
		for(int j=1;j<=m;j++){
			if(s[i][j]=='.')lst=j-1;
			else{
				if(j-lst>2||(s[i][j+1]!='#'&&j-lst>1))s[i][j]='1',lst=j;
				else s[i][j]='0';
			}
			cout<<s[i][j];
		}
		cout<<'\n';
	}
}
